/*
 *  Copyright 2010 johan.
 * 
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 * 
 *       http://www.apache.org/licenses/LICENSE-2.0
 * 
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  under the License.
 */

package nu.zoom.catonine.desktop.rule;

import java.awt.event.ActionEvent;

import nu.zoom.gal.error.ErrorReporter;
import nu.zoom.swing.action.AbstractTypedAction;
import nu.zoom.ui.Resources;
import nu.zoom.ui.Resources.ResourceNotFoundException;

/**
 * Action to import style rules from another collection of style rules.
 * 
 * @author "Johan Maasing" &lt;johan@zoom.nu&gt;
 */
public class ImportStyleRulesManagerAction extends AbstractTypedAction {
	private static final long serialVersionUID = 1L;
	private final StyleRulesPlugInImpl styleRulesPlugInImpl;
	private final ErrorReporter errorReporter;

	public ImportStyleRulesManagerAction(final StyleRulesPlugInImpl styleRulesPlugInImpl, final Resources messages,
			final ErrorReporter errorReporter) throws ResourceNotFoundException {
		this.styleRulesPlugInImpl = styleRulesPlugInImpl;
		this.errorReporter = errorReporter;
		setName(messages.getMessage("nu.zoom.catonine.configurations.import"));
		setToolTip(messages.getMessage("nu.zoom.catonine.configurations.import.tt"));
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		try {
			styleRulesPlugInImpl.importManager();
		} catch (Exception ex) {
			errorReporter.reportError(ex);
		}
	}

}
